package com.itheima.app.cotroller;

import com.itheima.app.manager.UserLikeManager;
import org.assertj.core.internal.bytebuddy.implementation.bytecode.constant.DefaultValue;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

@RestController
public class UserLikeController {

    @Autowired
    private UserLikeManager userLikeManager;
    //右滑喜欢
    @GetMapping("/tanhua/{likeUserId}/love")
    //@PostMapping("/users/fans/{likeUserId}")
    public void cardLove(@PathVariable Long likeUserId){
        userLikeManager.cardLove(likeUserId);
    }

    //左滑取消喜欢
    @GetMapping("/tanhua/{likeUserId}/unlove")
    //@DeleteMapping("/users/like/{likeUserId}")
    public void cardUnLove(@PathVariable Long likeUserId){
        userLikeManager.cardUnLove(likeUserId);
    }

    //统计关系
    @GetMapping("/users/counts")
    public ResponseEntity findUserLikeCountVo(){
       return userLikeManager.findUserLikeCountVo();
    }

    //我的详情
    @GetMapping("/users/friends/{type}")
    public ResponseEntity myDetail(
            @PathVariable Integer type,
            @RequestParam(value = "page",defaultValue = "1") Integer pageNum ,
            @RequestParam(value = "pagesize" , defaultValue = "10") Integer pageSize
    ){
        return userLikeManager.myDetail(type,pageNum ,pageSize);
    }

    //添加喜欢
    @PostMapping("/users/fans/{likeUserId}")
    public void addLove(@PathVariable Long likeUserId){
        userLikeManager.cardLove(likeUserId);
    }

    //取消喜欢
    @DeleteMapping("/users/like/{likeUserId}")
    public void removeLove(@PathVariable Long likeUserId){
        userLikeManager.cardUnLove(likeUserId);
    }

}
